home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
64'er
/
64ER_CD.iso
/
93xx
/
9301.d64
/
magische quadr.
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
1995-03-30
|
831b
|
20 lines
0 INPUT"[147]GROESSE";L:DIMA%(L,L):GOSUB5:S=L*(L*L+1)/2:INPUT"GA";G:INPUT"SA";T
1 INPUT"NAME";N$:A=LEN(STR$(L*L)):IFG=3THENA=3:R$(1)="[144]":R$(.)=""
2 PRINT"[147]":OPEN1,G,T,N$:CMD1:L$=" ":FORY=1TOL:FORX=1TOL:PRINTR$(X+YAND1);
3 PRINTRIGHT$(L$+STR$(A%(X,Y)),A);:NEXT:PRINT:NEXT:PRINT:PRINT"SUMME:"S
4 PRINT#1,"";:CLOSE1:END:DATA1,1,,,1,1,,,,,1,1,,,1,1
5 POKE53280,12:POKE53281,12:IFL/2>INT(L/2)THEN14
6 FORX=.TO3:FORY=.TO3:READA(X,Y):NEXT:NEXT:IFL/4>INT(L/4)THEN9
7 FORX=1TOL:FORY=1TOL:A%(X,Y)=X+Y*L-L:IFA(XAND3,YAND3)THENA%(X,Y)=L*L+1-A%(X,Y)
8 NEXT:NEXT:RETURN
9 L=L/2:GOSUB5:FORX=1TOL:FORY=1TOL:A%(X+L,Y+L)=A%(X,Y)+L*L
10 A%(X+L,Y)=A%(X,Y)+2*L*L:A%(X,Y+L)=A%(X,Y)+3*L*L:NEXT:NEXT:FORY=1TOL
11 FORX=1TOL/2-.5:GOSUB13:NEXT:IFL>3THENFORX=1.5*L+2.5TO2*L:GOSUB13:NEXT
12 NEXT:Y=L/2+.5:X=1:GOSUB13:X=Y:GOSUB13:L=L+L:RETURN
13 H=A%(X,Y):A%(X,Y)=A%(X,Y+L):A%(X,Y+L)=H:RETURN
14 X=L/2+.5:Y=L/2-.5:W=1
15 A%(X,Y)=W:X=X+1:Y=Y-1:IFX=L+1ANDY=.THENX=L:Y=L-1
16 X=X+L*(X>L):Y=Y-L*(Y<1):IFA%(X,Y)THENY=Y-1-L*(Y<2):X=X-1
17 W=W+1:IFW>L*LTHENRETURN
18 GOTO15